window.onload = function () {
    //电话号码验证
    var tel = document.querySelector("#tel");
    var reg1 = /^1[3|4|5|7|8]\d{9}$/; 
    regexp(tel, reg1);
    //短信验证
    var mesg = document.querySelector("#mesg");
    var reg2 = /^[\d]{6}$/;
    regexp(mesg, reg2);
    //输入密码
    var code = document.querySelector("#code");
    var reg3 = /^[\d\w]{16}$/;
    regexp(code, reg3);
    //确认密码
    var code2 = document.querySelector("#code2");
    code2.onblur = function () {
        if (this.value === code.value) {
            this.nextElementSibling.className = 'success';
            this.nextElementSibling.innerHTML = '<i class="success_icon"></i> 恭喜您输入正确'; 
        } else {
            this.value = "";
            this.nextElementSibling.className = 'error';
            this.nextElementSibling.innerHTML = '<i class="error_icon"></i> 密码应该保持一致！';
        }
    }

    function regexp(ele,reg) {
        ele.addEventListener("blur", function () {
            if (reg.test(this.value)) {
                this.nextElementSibling.className = 'success';
                this.nextElementSibling.innerHTML = '<i class="success_icon"></i> 恭喜您输入正确';
            } else {
                this.nextElementSibling.className = 'error';
                this.nextElementSibling.innerHTML = '<i class="error_icon"></i> 格式不正确，请从新输入';  
          }
    })
}









}